package com.example.demo.zaqizabatest.PC;

import static com.example.demo.zaqizabatest.PC.TestPC.*;

/**
 * @ClassName Consmer
 * @Author lys4134
 * @Date 2021/08/28 15:26:53
 * @Description Consmer
 * @Version 1.0
 **/
public class Consumer implements Runnable {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (queue) {
                if (!queue.isEmpty()) {
                    queue.poll();
                    System.out.println(Thread.currentThread().getName() + "消费商品");
                } else {
                    queue.notify();
                }
            }
        }
    }
}

